package chapter8;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;

public class CollectionTest {
    public static void main(String[] args) {
        Collection c = new ArrayList();
        c.add("leemz");
        c.add(5);
        System.out.println("c集合的元素个数:" + c.size());
        c.remove(5);
        System.out.println("c集合的元素个数:" + c.size());
        System.out.println("c集合是否包含\"leemz\"字符串:" + c.contains("leemz"));
        c.add("java");
        System.out.println("c集合的元素:" + c);
        Collection books = new HashSet();
        books.add("python");
        books.add("java");
        System.out.println("c集合是否完全包含books集合:" + c.containsAll(books));
        c.removeAll(books);
        System.out.println("c集合的元素:" + c);
        c.clear();
        System.out.println("c集合的元素:" + c);
        books.retainAll(c);
        System.out.println("books集合的元素:" + books);
    }
}
